/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function (nums) {
  let index = 1, tagValue = nums[0];
  for(let i = 1; i < nums.length; i++) {
    if(tagValue != nums[i]) {
      nums[index] = nums[i];
      index = index + 1;
      tagValue = nums[i];
    }
  }
  nums.length = index;
  return nums.length;
};


// // 测试样例
const num1 = [1, 1, 2];
const num2 = [0, 0, 1, 1, 1, 2, 2, 3, 3, 4];
const result1 = removeDuplicates(num1);
console.log(result1);
const result2 = removeDuplicates(num2);
console.log(result2);
// console.log(num1.splice(0, 1));
